<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //ES6 允许按照一定模式从数组对象中提取值，对变量进行赋值，被称为:解构赋值
        //1.数组的解构
        const F4 = ['小沈阳', '刘能', '张四', '宋小宝'];
        let [xiao, liu, zhang, song] = F4;
        console.log(xiao);
        console.log(liu);
        console.log(zhang);
        console.log(song);

        //2.对象的解构
        const zhao = {
            name: '赵本山',
            sex: '男',
            age: 67,
            xiaopin: function () {
                console.log('我爱演小品!!!');
            }
        };
        let {name, sex, age, xiaopin} = zhao;
        console.log('2.name:' + name);
        console.log('2.sex:' + sex);
        console.log('2.age:' + age);
        xiaopin();
        
        //3.函数与解构赋值相结合
        function connect({localhost,username,password,port}) {
             console.log('3域名:' + localhost);
             console.log('3用户名:' + username);
             console.log('3.密码:' + password);
             console.log('3.端口号:' + port);
        }
        connect({
            localhost:'127.0.0.1',
            username:'root',
            password:'root',
            port:3306
        })
    </script>
</body>

</html>